<?php
/**
 * @author      :   HungNT1
 * @name        :   Euro2012_TeamController
 * @copyright   :   Fpt Online
 * @todo        :   Euro2012_TeamController
 */
class Euro2012_TeamController extends Zend_Controller_Action {

    /**
     * init of controller
     */
    public function init()
    {
        //Disable layout
        //$this->_helper->layout->setLayout('common');

    }

    //index action
    public function indexAction()
    {
        //get team euro
        $modelTeamSeason = TeamSeason::getInstance();

        //get team euro
        $arrTeamEuro = $this->view->arrTableMatch;

        $this->view->arrTeamEuro = $arrTeamEuro;

        //----------------------------------------------------------------------
        //get video newest
        
    }

    public function playerofteamAction()
    {
        $this->_helper->layout->disableLayout(true);
        //$this->_helper->viewRenderer->setNoRender(true);

        //get param teamid
        $team_id = $this->_request->getParam('team_id', NULL);

        //----------------------------------------------------------------------
        //get player of team with team id

        $modelPlayer = Player::getInstance();

        $arrPlayer = $modelPlayer->getPlayerByTeamId($team_id);

        //----------------------------------------------------------------------
        //Thu mon
        $arrK = array();        
        //Tien dao
        $arrF = array();        
        //Tien ve
        $arrM = array();        
        //Hau ve
        $arrD = array();
        //Hau cong
        $arrSUB = array();
        if (!empty ($arrPlayer))
        {
            foreach ($arrPlayer as $player)
            {
                switch ($player['position'])
                {
                    case 'D':
                        $arrD[] = $player;
                        break;
                    case 'F':
                        $arrF[] = $player;
                        break;
                    case 'M':
                        $arrM[] = $player;
                        break;
                    case 'K':
                        $arrK[] = $player;
                        break;
                    case 'SUB':
                        $arrSUB[] = $player;
                        break;
                }
            }
        }
        $this->view->arrPlayer = $arrPlayer;
        $this->view->arrD = $arrD;
        $this->view->arrF = $arrF;
        $this->view->arrM = $arrM;
        $this->view->arrK = $arrK;
        $this->view->arrSUB = $arrSUB;        
    }

    public function playerAction()
    {
        
        //get player id
        $player_id = $this->_request->getParam('playerid', NULL);

        //----------------------------------------------------------------------
        //get information of player

        //get model player
        $modelPlayer = Player::getInstance();

        $arrPlayer = $modelPlayer->getDetail($player_id);

        $this->view->arrPlayer = $arrPlayer;

        
        //----------------------------------------------------------------------
        //get cau thu cua doi bong lien quan
        $arrPlayerOfTeam = $modelPlayer->getPlayerByTeamId($arrPlayer['team_id']);

        if (!empty ($arrPlayerOfTeam))
        {
            $arrTmp = array();
            foreach ($arrPlayerOfTeam as $player)
            {
                $arrTmp[$player['player_id']] = $player;
            }

            $arrPlayerOfTeam = $arrTmp;
        }
        
        $this->view->arrPlayerOfTeam = $arrPlayerOfTeam;

        
    }


}